package com.alfa.myworld.server;

import javax.jdo.PersistenceManager;
import com.alfa.myworld.client.NewUserService;
import com.alfa.myworld.server.domain.User;
import com.alfa.myworld.shared.UserDto;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class NewUserServiceImpl extends RemoteServiceServlet implements NewUserService{

	@Override
	public Boolean createUserAccount(UserDto userDto) {
		User newUser = new User(); 
		newUser.setFirstName(userDto.getFirstName());
		newUser.setLastName(userDto.getLastName()); 
		newUser.setEmail(userDto.getEmail()); 
		
		PersistenceManager pm = PMF.get().getPersistenceManager(); 
		try{
			pm.makePersistent(newUser);
		}finally{
			pm.close(); 
		}		
		return new Boolean(true); 			
	}	
}
